package com.example.servicearea.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.servicearea.dahua.PersonCapture;
import com.example.servicearea.dahua.ProcessThread;

import com.example.servicearea.dao.DeviceDao;
import com.example.servicearea.domain.DeviceDate;
import com.example.servicearea.service.IDevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceService extends ServiceImpl<DeviceDao, DeviceDate> implements IDevice {

    @Autowired
    private DeviceDao deviceDao;

    public List<DeviceDate> SelectDeviceInfo(Integer id){

        return deviceDao.selectDeviceInfo(id);
    }

    public void loginDevice(String ip, String admin, String password ,Integer deviceId , String deviceType){
        PersonCapture device =new PersonCapture(deviceId,ip,37777,admin,password,deviceType);
        ProcessThread pt=new ProcessThread(device);
        pt.start();
    }

    public String selectServiceName(){
        return deviceDao.selectDeviceName();
    }

    public Integer selectDeviceState(Integer id){return deviceDao.selectDeviceState(id);}

    public Integer updateDeviceStateById(int deviceId){
        return deviceDao.updateDeviceState(deviceId);
    }
}
